﻿using System.Linq;
using System.Web;

namespace Config
{
    public class UrlMaker
    {

        public static string WebHost
        {
            get
            {
                //if (!string.IsNullOrEmpty(UrlParram.MerchantName))
                //{
                //    var host = HttpContext.Current.Request.Url.Host;
                //    if (SettingValues.MerchantDomains.ContainsKey(host))
                //    {
                //        return "http://" + host;
                //    }

                //    return string.Format("http://{0}.{1}", UrlParram.MerchantName, SettingValues.RootDomain);
                //}

                return "http://byhand.vn";
                //return !string.IsNullOrEmpty(UrlParram.MerchantName)
                //           ? string.Format("http://{0}.{1}", UrlParram.MerchantName,SettingValues.RootDomain)
                //           : "http://guu.vn";
            }
        }
       

        public static string Host
        {
            get
            {

               
                //if(UrlParram.IsApp)
                //{
                //    return !string.IsNullOrEmpty(UrlParram.MerchantName)
                //           ? string.Format("http://{0}.{1}/app", UrlParram.MerchantName, SettingValues.RootDomain)
                //           : "http://guu.vn";
                //}


                //if (!string.IsNullOrEmpty(UrlParram.MerchantName))
                //{
                //    return "";
                //    //var host = HttpContext.Current.Request.Url.Host;
                //    //if (SettingValues.MerchantDomains.ContainsKey(host))
                //    //{
                //    //    return "http://" + host;
                //    //}

                //    //return string.Format("http://{0}.{1}", UrlParram.MerchantName, SettingValues.RootDomain);
                //}

                return "http://byhand.vn";
                //return !string.IsNullOrEmpty(UrlParram.MerchantName)
                //           ? string.Format("http://{0}.{1}", UrlParram.MerchantName,SettingValues.RootDomain)
                //           : "http://guu.vn";
            }
        }
        public static string ToDefault(int pageindex)
        {
            if (pageindex > 0)
                return Host + "?pageindex=" + pageindex;
            return Host;
        }
        public static string ToDetailArticle(int articleid, int pageindex, string txt)
        {
            return string.Format("{0}/bai-viet/{1}/{2}", Host, articleid, txt);
        }

        public static string ToDetailProduct(int productid, int pageindex, string txt)
        { 
            return string.Format("{0}/san-pham/{1}/{2}/{3}", Host, productid, pageindex, txt);
        }

        public static string ToDetailProduct(string merchantname,int productid, int pageindex, string txt)
        {
            return string.Format("{0}/san-pham/{1}/{2}/{3}", string.Format("http://{0}.{1}", merchantname, "http://byhand.vn"), productid, pageindex, txt);
        }
        public static string ToRedirectCheckOrder(string ordercode)
        {
            return string.Format("{0}/redirect/{1}", Host, ordercode);
        }
        /*
        
        public static string ToAppRedirectDetailProduct(int productid)
        {
            return string.Format("{0}{1}", "", string.Format("Home/GetAppRedirectDetailProduct?merchantname={0}&productid={1}", Merchantname, productid));
        }
        */

        public static string ToListProductByTag(int tagid, int pageindex, string txt)
        {
            return string.Format("{0}/chuyen-muc/{1}/{2}/{3}", Host, tagid, pageindex, txt);
        }
        public static string ToListProductByPrice(int price, int pageindex, string txt)
        {
            return string.Format("{0}/gia-tien/{1}/{2}/{3}", Host, price, pageindex, txt);
        }

        public static string ToListProductByColor(string color, int pageindex, string txt)
        {
            return string.Format("{0}/mau-sac/{1}/{2}/{3}", Host, color, pageindex, txt);
        }
        public static string ToListProductBySize(string size, int pageindex, string txt)
        {
            return string.Format("{0}/kich-co/{1}/{2}/{3}", Host, size, pageindex, txt);
        }

        public static string ToListProductByKeyword(string keyword, int pageindex, string txt)
        {
            return string.Format("{0}/tim-kiem/{1}/{2}/{3}", Host, keyword, pageindex, txt);
        }

        public static string ToPostSearchProduct()
        {

            return string.Format("{0}/Product/Search", Host);
        }
        public static string ToPostCommentProduct()
        {
            return string.Format("{0}/Product/Comment", Host);
        }


    }
}